<template>
	<view>
		<view class="sort-content">
			<!--无内容显示-->
			<u-empty v-if="feedbackList.length < 1" margin-top="400" text="暂无申请" mode="data" icon-size="150"></u-empty>
			<!--按时间排序 -->
			<view v-if="feedbackList.length > 0" v-for="(item, index) in feedbackList" :key="index" style="padding: 0rpx 10rpx;">
				<view class="sort-content-item">
					<view class="sort-content-top" style="display: flex;align-items: center;justify-content: space-between;">
						<view class="user-info">
							<view class="user-photo"><image src="../../../../static/img/user/missing-face.png" mode="scaleToFill"></image></view>
							<view class="user-detail">
								<view class="user-name text-name">
									<text>{{ item.data.nickName }}</text>
								</view>
							</view>
						</view>
						<view class="margin-right-sm text-lg text-bold">{{item.data.type}}</view>
					</view>
					<view class="sort-content-middle margin-top-xs">
						<view class="acticle-text text-black">
							<text>{{ item.data.content }}</text>
						</view>
						<view class="acticle-image" v-if="item.data.imagelist.length > 0">
							<scroll-view scroll-x="true" class="show margin-top-xs">
								<image
									v-for="(itemtp, index) in item.data.imagelist"
									:key="index"
									:src="itemtp"
									mode="aspectFill"
									style="width:150rpx;height:150rpx;border-radius:5rpx;margin-right: 20rpx;"
									@click="previewImage(item.data.imagelist)"
									class="animation-fade imageshow"
								></image>
							</scroll-view>
						</view>
					</view>
					<view class="sort-content-bottom">
						<view class="content-bottom-box">
							<uni-dateformat :threshold="[60000, 6048000000]" class="content-text-ps text-gray margin-left-xs" :date="item.data.time"></uni-dateformat>
						</view>
						<view class="caozuo-button bg-gradual-blue" @click="tosetFeekback(item._id, index)"><view class="text-sm">已处理</view></view>
					</view>
				</view>
			</view>
		</view>
		<!--//置顶结束 -->
		<!-- //消息弹窗 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
//数据库引入
const db = uniCloud.database();
const dbCmd = db.command;
//引入全局变量
var app = getApp();
export default {
	data() {
		return {
			feedbackList: []
		};
	},
	onLoad() {},
	onShow() {
		let that = this;
		//加载反馈模块数据  提取状态为0的 状态为1的表示已处理
		that.getfeedbackList();
	},
	methods: {
		//加载反馈模块数据
		getfeedbackList() {
			let that = this;
			db.collection('feedback')
				.orderBy('data.time', 'desc')
				.where({
					'data.state': 0
				})
				.get({})
				.then(res => {
					console.log('反馈数据列表', res.result.data);
					that.feedbackList = res.result.data;
				});
		},
		//反馈确认
		tosetFeekback(id, index) {
			let that = this;
			uni.showModal({
				title: '温馨提示!',
				content: '是否确认该问题已解决?',
				success(res) {
					if (res.confirm) {
						console.log('开始处理');
						db.collection('feedback')
							.doc(id)
							.update({
								data:{
									state: 1
								}
							})
							.then(res => {
								that.$refs.uToast.show({
									title: '已处理！',
									type: 'success'
								});
								setTimeout(function() {
									//本地数据处理
									that.feedbackList.splice(index,1);
								}, 800);
							})
							.catch(err => {
								that.$refs.uToast.show({
									title: '网络出错啦！',
									type: 'error'
								});
							});
					}
				}
			});
		},
		//图片预览
		previewImage(imagelist) {
			uni.previewImage({
				urls: imagelist,
				current: imagelist[0],
				success: function(res) {},
				fail: function(res) {},
				complete: function(res) {}
			});
		}
	}
};
</script>

<style lang="scss">
// 底部操作按钮
.caozuo-button {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-left: 50rpx;
	border-radius: 25rpx;
	width: 130rpx;
	height: 50rpx;
}
/* 分类具体内容 */
.sort-content {
	justify-content: center;
	margin: auto;
	width: 96vw;
	margin-left: 2vw;
	margin-top: 20rpx;
	margin-bottom: 20rpx;
	transition: all 0.5s ease-in-out;
}

.sort-content-item {
	margin-top: 20rpx;
	padding-bottom: 15rpx;
	padding-top: 20rpx;
	border-radius: 10rpx;
	// border-bottom: 3rpx rgb(208, 208, 208) solid;
	background-color: #ffffff;
	box-shadow: 0rpx 2rpx 3rpx 2rpx rgba(0, 0, 0, 0.1);
	transition: all 0.5s ease-in-out;
}

.user-info {
	width: 80vw;
	height: 30px;
	padding: 0 30rpx 10rpx 10rpx;
	margin-top: 5rpx;
	display: flex;
	flex-direction: row;
	justify-content: center;
	align-items: center;
}

.user-photo {
	width: 40px;
	height: 40px;
	display: flex;
	flex-direction: row;
	justify-content: center;
	margin-left: 10px;
}

.user-info image {
	width: 40px;
	height: 40px;
	border-radius: 50%;
}

.user-detail {
	display: flex;
	flex-direction: column;
	flex-grow: 2;
	margin-left: 5px;
}

.user-fire {
	height: 50rpx;
	display: flex;
	align-items: center;
	justify-content: center;
}

.user-name {
	margin-top: -10px;
	font-size: 25rpx;
	font-weight: 500;
	letter-spacing: 3rpx;
}

.text-name {
	margin-left: 8px;
	color: rgba(0, 71, 255, 0.6);
}

.user-flag {
	display: flex;
	flex-direction: row;
	width: 65px;
	height: 22px;
	text-align: center;
	// border: solid 1px #000000;
	border-radius: 11px;
	box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.15);
}

.user-flag view {
	font-weight: 100;
	color: black;
	font-size: 10px;
	margin-top: 3px;
	background-color: #00000000;
	width: 65px;
	text-align: center;
}

.article-sort {
	background-color: #ffffff;
}

.user-sex {
	background-color: chocolate;
}

.user-level {
	background-color: cornflowerblue;
}

.sort-content-middle {
	width: 100%;
	// border: 2px solid #000000;
	text-align: center;
	margin-left: 40rpx;
	// margin-top: -10rpx;
}

.acticle-text {
	word-wrap: break-word;
	font-size: 30rpx;
	display: -webkit-box;
	text-align: left;
	padding: 0 20rpx 0 0;
	overflow: hidden;
	margin-left: 0rpx;
	-webkit-line-clamp: 30;
	-webkit-box-orient: vertical;
	letter-spacing: 3rpx;
}

.acticle-image {
	display: flex;
	height: auto;
	flex-wrap: wrap;
}

.show {
	width: 100%;
	height: 150rpx;
	display: flex;
	text-align: start;
	white-space: nowrap;
}

.show-image image {
	display: inline-block;
	width: 100%;
	height: 100%;
	margin: 5rpx;
	border-radius: 10rpx;
}

/* 更多 */
.post-detail {
	display: block;
	height: 80%;
	width: 200rpx;
}

.handle {
	padding-left: 170rpx;
}

.handle image {
	width: 35rpx;
	height: 35rpx;
	text-align: right;
}

.post-time {
	margin-top: -20rpx;
	display: block;
	float: right;
}

.post-time text {
	font-size: 22rpx;
	color: #a09c9c;
}

/* 底部评论等 */
.bottom-img {
	width: 35rpx;
	height: 35rpx;
	vertical-align: middle;
}

.sort-content-bottom {
	width: 90%;
	height: 52rpx;
	margin-top: 20rpx;
	margin-left: 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.content-bottom-box {
	display: flex;
	align-items: center;
}

.content-text-ps {
	font-size: 24rpx;
}
</style>

